package com.example.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.bean.Orders;
import com.example.bean.ResultVo;
import com.example.mapper.OrdersMapper;
import com.example.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName OrderServiceImpl
 * @Author 冯泽嘉
 * @Date 2021/10/3 18:13
 */

@Service(value = "OrderService")
public class OrderServiceImpl extends ServiceImpl<OrdersMapper, Orders> implements OrderService {

    @Autowired
    OrdersMapper ordersMapper;


    /**
     * 第一版
     */
    @Override
    public ResultVo getOrdersAll() {
        return new ResultVo(ordersMapper.getOrdersAll());
    }

    @Override
    public ResultVo getOrdersAllUser(int uid) {
        return new ResultVo(ordersMapper.getOrdersAllUser(uid));
    }

    @Override
    public ResultVo getOrdersAllMerchant(int mid) {
        return new ResultVo(ordersMapper.getOrdersAllMerchant(mid));
    }

    @Override
    public ResultVo findOrderByOrderNumberUser(String orderNumber, int uid) {
        return new ResultVo(ordersMapper.findOrderByOrderNumberUser(orderNumber, uid));
    }

    @Override
    public ResultVo findOrderByOrderNumberMerchant(String orderNumber, int mid) {
        return new ResultVo(ordersMapper.findOrderByOrderNumberMerchant(orderNumber, mid));
    }

    @Override
    public ResultVo findOrderByMNameUser(String mName, int uid) {
        return new ResultVo(ordersMapper.findOrderByMNameUser(mName, uid));
    }

    @Override
    public ResultVo findOrderByMNameMerchant(String mName, int mid) {
        return new ResultVo(ordersMapper.findOrderByMNameMerchant(mName, mid));
    }

    @Override
    public ResultVo deleteOrderByOrderNumber(String orderNumber) {
        return new ResultVo(ordersMapper.deleteOrderByOrderNumber(orderNumber));
    }


    /**
     * 第二版（商家）
     */
    @Override
    public ResultVo findOrdersAllMerchant2(int mid) {
        return new ResultVo(ordersMapper.findOrdersAllMerchant2(mid));
    }

    @Override
    public ResultVo findOrderByOrderNumberMerchant2(String orderNumber, int mid) {
        return new ResultVo(ordersMapper.findOrderByOrderNumberMerchant2(orderNumber, mid));
    }

    @Override
    public ResultVo findOrderByNameMerchant2(String gName, int mid) {
        return new ResultVo(ordersMapper.findOrderByNameMerchant2(gName, mid));
    }

    @Override
    public ResultVo modifyOrderMerchant2(int uid, int gid, int mid, String oName, String oPhone, String oAddress, String cNumber) {
        return new ResultVo(ordersMapper.modifyOrderMerchant2(uid, gid, mid, oName, oPhone, oAddress, cNumber));
    }

    @Override
    public ResultVo changeOrderState2(String oState, int uid, int gid, int mid, String cNumber) {
        return new ResultVo(ordersMapper.changeOrderState2(oState, uid, gid, mid, cNumber));
    }

    /**
     * 第二版（用户）
     */
    @Override
    public ResultVo findOrdersAllUser2(int uid) {
        return new ResultVo(ordersMapper.findOrdersAllUser2(uid));
    }

    @Override
    public ResultVo findOrderByOrderNumberUser2(String orderNumber, int uid) {
        return new ResultVo(ordersMapper.findOrderByOrderNumberUser2(orderNumber, uid));
    }

    @Override
    public ResultVo findOrderByNameUser2(String gName, int uid) {
        return new ResultVo(ordersMapper.findOrderByNameUser2(gName, uid));
    }

    @Override
    public ResultVo findOrderByStateUser2(String oState, int uid) {
        return new ResultVo(ordersMapper.findOrderByStateUser2(oState, uid));
    }

    @Override
    public ResultVo ChangeStateUser(String orderstate, int uid, String orderNumber) {
        return new ResultVo(ordersMapper.ChangeStateUser(orderstate, uid, orderNumber));
    }

    @Override
    public String findNewstOrder(int uid) {
        return ordersMapper.findNewstOrder(uid);

    }

    @Override
    public boolean reInventory(int gid){
        return ordersMapper.reInventory(gid);
    }
}
